@extends('adminDialog')
@section('content')
    <div class="table_list">
        <div id="data_list">
            <table class="items">
                <thead>
                <tr>
                    <th>ID</th>
                    <th>类型</th>
                    <th>可投金额</th>
                    <th>收益周期</th>
                    <th>年化收益</th>
                    <th>结束收益</th>
                    <th>操作</th>
                </tr>
                <tbody>
                @foreach( $item as $key=>$value )
                    <tr>
                        <td>{{$value->id}}</td>
                        <td>{{$value->mold}}</td>
                        <td>{{$value->price}}</td>
                        <td>{{$value->cycle}}</td>
                        <td>{{$value->income}}</td>
                        <td>{{$value->end}}</td>
                        <td>
                            <a href="{{url('admin/financial/deletepackage/'.$value->id)}}" class="mr10 J_ajax_del">[删除]</a>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="summary">
            共有 {{count($item)}} 条数据
        </div>
    </div>
    <form action="{{url('admin/financial/package/'.$id)}}" method="POST" class="J_ajaxForm">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <div class="pop_cont pop_table" style="overflow-y: scroll;">
            <table width="100%">
                <tbody>
                <tr>
                    <th>
                        <label for="title">可投金额</label>
                    </th>
                    <td>
                        <input type="text" name="price" id="" class="input length_6"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="title">可投金额类型</label>
                    </th>
                    <td>
                        <input type="text" name="mold" id="" class="input length_6" />
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="title">收益周期</label>
                    </th>
                    <td>
                        <input type="text" name="cycle" id="" class="input length_6"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="title">年化收益</label>
                    </th>
                    <td>
                        <input type="text" name="income" id="" class="input length_6"/>
                    </td>
                </tr>
                <tr>
                    <th>
                        <label for="title">结束收益</label>
                    </th>
                    <td>
                        <input type="text" name="end" id="" class="input length_6"/>
                    </td>
                </tr>

                </tbody>
            </table>
        </div>

        <div class="pop_bottom cc">
            <button type="reset" class="btn fr" id="J_dialog_close">取消</button>
            <button type="submit" class="btn btn_submit J_ajax_submit_btn fr mr10" id="J_dialog_close">提交</button>
        </div>
    </form>
@stop

@section('style')
    <style type="text/css">
        .body_none {
            width: 720px;
        }
    </style>
@stop

@section('js')
    @parent
    @include('UEditor::head')
    <script src="{{ asset('js/plupload/plupload.full.min.js') }}"></script>
    <script>
        var ue = UE.getEditor('container', {
            initialFrameWidth: 600, initialFrameHeight: 300, autoHeightEnabled: false, toolbars: [
                ['source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc'],
                ['link', 'simpleupload', 'insertimage']
            ]
        });
        var ue = UE.getEditor('container1', {
            initialFrameWidth: 600, initialFrameHeight: 300, autoHeightEnabled: false, toolbars: [
                ['source', 'undo', 'redo', 'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc'],
                ['link', 'simpleupload', 'insertimage']
            ]
        });
        ue.ready(function () {
            ue.execCommand('serverparam', '_token', "{{ csrf_token() }}");//此处为支持laravel5 csrf ,根据实际情况修改,目的就是设置 _token 值.
        });
    </script>
    <script>
        $(function () {
            var uploader = new plupload.Uploader({
                runtimes: 'html5,flash,silverlight,html4',
                browse_button: 'pickfiles', // you can pass in id...
                //container: document.getElementById('container'), // ... or DOM Element itself
                url: "{{ url('upimg') }}",
                filters: {
                    max_file_size: '5mb',
                    mime_types: [
                        {title: "Image files", extensions: "jpg,gif,png"}
                    ]
                },
                multi_selection: false,
                file_data_name: 'file',
                multipart_params: {'_token': '{{ csrf_token() }}', 'dir': 'financial'},
                // Flash settings
                flash_swf_url: '{{ asset("js/plupload/Moxie.swf") }}',
                // Silverlight settings
                silverlight_xap_url: '{{ asset('js/plupload/Moxie.xap') }}',

                init: {
                    PostInit: function () {
                        return false;
                    },
                    FilesAdded: function (up, file) {
                        $('.up-pic img').attr('src', '{{ asset('images/loading.gif') }}');
                        uploader.start();
                    },
                    Error: function (up, err) {
                        tips(err.message);
                    },
                    BeforeUpload: function(uploader,file){
                        if($(".uploadimg span img").length > 1){
                            alert("最多只能上传2张商品图片");
                            uploader.stop();
                            return;
                        }
                    },
                    FileUploaded: function (up, file, responseObj) {
                        var response = $.parseJSON(responseObj.response);
                        if (response.state == 'success') {
                            var　imgString = '<span><img title="商品图片" src="' + response.src + '"/><input type="hidden" name="images[]" value="' + response.src + '"/><a href="javascript:void(0);">X</a></span>';
                            $(".uploadimg").prepend(imgString);

                        } else {
                            tips(response.message);
                        }
                    }
                }
            });
            uploader.init();

            $(".uploadimg").on("click", "span a", function(){
                $(this).parent().remove();
            });

        });

    </script>
@stop
